(function() {
    window.FeishiUtil = window.FeishiUtil || {};

    FeishiUtil.orderAjax=function () {
        return new OrderAjax();
    };
    function OrderAjax() {
        this.listExecute=[];
        this.callBacks={};
        this.index=0;
        this.execueIndex=0;
    }
    OrderAjax.prototype.ajax=function(param) {
        console.info("execute ajax");
        var thisObj=this;
        var index=this.index++;
        var executor={
            id:index,
            fun:param.success
        };
        this.listExecute.push(executor);
        param.success=function () {
            thisObj.execue(executor,arguments);
        };
        $.ajax(param);
    };
    OrderAjax.prototype.execue=function (executor,args) {
        executor.args=args;
        this.callBacks[executor.id]=true;
        this.tryToExecute();
    };
    OrderAjax.prototype.tryToExecute=function () {
        for (var i=this.execueIndex;i<this.listExecute.length;i++){
            if(this.callBacks[this.listExecute[i].id]){
                this.listExecute[i].fun.apply({},this.listExecute[i].args);
                this.execueIndex++;
            }else{
                break;
            }
        }
    };

})();